/**
 * 滑块
 * 水平滑块
 */
var MySlider = {
	/**
	 * 水平滑块
	 * @param {} option 属性
	 *   {pcId} 父容器对象id 不能为空
	 *   {domains:[min,max]} 阀值数组
	 *   {end:double} 尾值(阀值为小数时=1)
	 *   {val:double} 阀值，
	 *   {width:int} 宽，默认180
	 *   {height:int} 高(滑块轴高度，不包括标尺高度)，默认20
	 *   {block:int} 块数(滑块个数)，默认3
	 *   {colors:[]} 色值数组(colors.length=block)
	 *   {arrowSize:int} 游标箭头尺寸
	 */
	hSlider: function(option){
		this.pcId;
		this.val = 80;
		this.domains = [0, 60, 120, 180];
		this.bock = 3;
		this.arrowSize = 21;
		// 绿黄红
		this.COLORS = ['#8bbf3a','#ffff00','#ff0000'];
		this.CURSOR_IMG_URL = {
				'#8bbf3a': CONTEXT_PATH +'/assets/proj/images/icon_t_g_d.png',
				'#ffff00': CONTEXT_PATH +'/assets/proj/images/icon_t_y_d.png',
				'#ff0000': CONTEXT_PATH +'/assets/proj/images/icon_t_r_d.png'
		};
		this.hcUrl = this.CURSOR_IMG_URL['#8bbf3a'];
		/**
		 * css {}
		 */
		this.css = {
				'height': 20
				,'width': 180
				,'colors': this.COLORS
				,'cursor-sec-x': 80
		};
		/**
		 * 初始化设置默认值
		 * @param option
		 */
		this.init = function(option){
			if(typeof(option.block) == 'undefined'){
				if(typeof(option.domains) == 'undefined'){
					option.block = this.block;
					option.domains = this.domains;
				}else{
					// 拼上首-0 尾-end 值
					//option.domains = [0, option.domains[0], option.domains[1], option.end];
					option.block = option.domains.length - 1;
				}
			}else{
				if(typeof(option.domains) == 'undefined'){
					var c = 180 / option.block;
					var ds = [option.block + 1];
					for(var i = 0; i <= option.block; i++){
						ds[i] = i * c;
					}
					option.domains = ds;
				}else{
					// 拼上首-0 尾-end 值
					//option.domains = [0, option.domains[0], option.domains[1], option.end];
				}
			}
			if(typeof(option.colors) != 'undefined'){
				this.css['colors'] = option.colors;
			}
			if(typeof(option.width) == 'undefined'){
				option.width = this.css['width'];
			}else{
				this.css['width'] = option.width;
			}
			if(typeof(option.height) == 'undefined'){
				option.height = this.css['height'];
			}else{
				this.css['height'] = option.height;
			}
			if(typeof(option.val) == 'undefined'){
				option.val = this.val;
			}
			if(typeof(option.arrowSize) == 'undefined'){
				option.arrowSize = this.arrowSize;
			}
			
			this.pcId = option.pcId;
			this.domains = option.domains;
			this.val = option.val;
			this.block = option.block;
			this.arrowSize = option.arrowSize;
			// 游标位置min:domains[1] max:domains[2]
			var min = this.domains[1];
			var max = this.domains[2];
			if(this.val < min){
				// 小于最小阀值，第一块
				this.hcUrl = this.CURSOR_IMG_URL[this.css['colors'][0]];
			}else if(this.val >= max){
				// 大于最大阀值，第三块
				this.hcUrl = this.CURSOR_IMG_URL[this.css['colors'][2]];
			}else{
				// 介于最大最小阀值之间，第一块
				this.hcUrl = this.CURSOR_IMG_URL[this.css['colors'][1]];
			}
			
		};
		/**
		 * 创建块
		 */
		this.create = function(){
			var len = this.domains.length;
			// 所有块(所有块)宽度
			var abw = this.css['width'];
			// 阀值单位宽度：宽度 / 阀值跨度(最大(后)阀值/最小(前)阀值)
			var unit = abw / (this.domains[len - 1] - this.domains[0]);
			// 左侧块宽：unit * (第二个阀值-第一个阀值)
			var lw = unit * (this.domains[1] - this.domains[0]);
			// 中间每个块宽：unit * ((倒数第二个阀值-第二个阀值)/除了首尾块剩下的块数(块数-2))
			var cw = unit * ((this.domains[len - 2] - this.domains[1]) / (this.block - 2));
			// 右侧块宽：unit * (最大(后)阀值-倒数第二个阀值)
			var rw = unit * (this.domains[len - 1] - this.domains[len - 2]);
			// 左侧块
			var ld = '';
			// 中间块
			var cd = '';
			// 右侧块
			var rd = '';
			for(var i = 0; i < this.block; i++){
				if(i == 0){
					ld = '<div'+ this.style('left', lw, i) +'></div>';
				}else if(i == (this.block - 1)){
					rd = '<div'+ this.style('right', rw, i) +'></div>';
				}else{
					cd += '<div'+ this.style('center', cw, i) +'></div>';
				}
			}
			// 整个div高度：高度+游标div高度
			var adh = this.css['height'] + this.arrowSize;
			// 整个div宽度：div宽度+游标宽度(两侧各流出游标一半的宽，当val=min/val=max时不会出现游标图片显示一半的问题)
			var adw = abw + this.arrowSize;
			// 游标X位置：unit * (阀值-最小(前)阀值) - arrowSize(游标宽度)/2 + arrowSize(游标宽度)/2
			this.css['cursor-sec-x'] = unit * (this.val - this.domains[0]);
			// 游标div
			var curd = '<div id="'+ this.pcId +'_cursor_sec"'+' style="height: '+ this.arrowSize +'px;width: '+ adw +'px;"></div>';
			// 滑块div：<div>+左侧块div+中间块div+右侧块div+</div>
			var sd = '<div style="width: '+ adw +'px;height: '+ this.css['height'] +'px;padding-left: '+ this.arrowSize/2 +'px">'+ ld + cd + rd +'</div>';
			// 添加到父div，游标div+滑块div
			$('#'+ this.pcId).html(curd + sd);
			// 父div宽高
			$('#'+ this.pcId).width(adw);
			$('#'+ this.pcId).height(adh);
			// 设置游标div背景图片，三角位置
			$('#'+ this.pcId +'_cursor_sec').css('background', 'url("'+ this.hcUrl +'") '+ this.css['cursor-sec-x'] +'px center no-repeat');
			$('#'+ this.pcId +'_cursor_sec').css('background-size', this.arrowSize +'px '+ this.arrowSize +'px');
		};
		this.style = function(sec, w, idx){
			var v = 'float: left;';
			v += 'height: '+ this.css['height'] +'px;';
			v += 'width: '+ w +'px;';
			v += 'background: '+ this.css['colors'][idx] +';';
			return ' style="'+ v +'" ';
		};
		/**
		 * 随机颜色数组
		 * @param count
		 * @returns {Array}
		 */
		this.randomColors = function(count){
			var cs = [];
			if(typeof(count) != 'undefined'){
				for(var i = 0; i < count; i++){
					cs[i] = '#'+ ('00000'+ ((Math.random() * 16777215 + 0.5) >> 0).toString(16)).slice(-6);
				}
			}
			return cs;
		};
		this.init(option);
		this.create();
	}
	/**
	 * 垂直滑块
	 */
	,vSlider: function(option){
		
	}
	/**
	 * 工业/商业存销比滑块
	 * @param {}
	 * {ds: [{},...]} 数据源，json数组不能为空
	 * {val: number} 值，不能为空
	 * {pcId: string} 父控件id，不能为空
	 * {dsKeys: ['',...]} 数据源key['预警状态key','最小阀值key','最大阀值key']顺序不能变,默认['THRSHD_STTS','MIN_THRSHD','MAX_THRSHD']
	 * {width: int} 滑块宽度(不包括两端各游标箭头一半宽度),默认130
	 * {height: int} 滑块高度(不包括上部游标箭头高度),默认20
	 * {arrowSize: int} 游标箭头尺寸,默认20
	 * {gap: int} 间隙,默认5
	 */
	,ibHSlider: function(option){
		// 数据源key['预警状态key','最小阀值key','最大阀值key']
		this.dsKeys = ['THRSHD_STTS','MIN_THRSHD','MAX_THRSHD'];
		// 父控件id
		this.pcId;
		// 块颜色值(红黄绿)
		this.colors = ['#ff0000', '#ffff00', '#8bbf3a'];
		// 游标箭头三角(红黄绿)
		this.cursorArrow = [
		    CONTEXT_PATH +'/assets/proj/images/icon_t_g_d.png'
 		    ,CONTEXT_PATH +'/assets/proj/images/icon_t_y_d.png'
	    	,CONTEXT_PATH +'/assets/proj/images/icon_r_d.png'];
		// 值状态(1-绿色安全 2-黄色警告 3-红色预警),默认绿
		this.status = 1;
		// 间隙,默认5
		this.gap = 5;
		// 宽(块宽),不包含两侧半个游标箭头宽,默认130
		this.width = 130;
		// 滑块下部高,不包含上部游标箭头高,默认20
		this.height = 20;
		// 游标箭头尺寸,默认20
		this.arrowSize = 20;
		/**
		 * 判断当前值预警状态
		 * 最小阀值取等于，最大阀值是不等于
		 */
		this.judge = function(option){
			if(typeof(option.ds) === 'undefined' || typeof(option.ds) === 'null'
					|| typeof(option.val) === 'undefined' || typeof(option.val) === 'null'
					|| typeof(option.pcId) === 'undefined' || typeof(option.pcId) === 'null'){
				return false;
			}
			if(!(option.ds instanceof Array)){
				return false;
			}
			if(typeof(option.dsKeys) != 'undefined'){
				this.dsKeys = option.dsKeys;
			}
			var min,max,status=null,val = Number(option.val),ds = option.ds,isFind = false;
			for(var i = 0; i < ds.length; i++){
				min = ds[i][this.dsKeys[1]];// 最小阀值
				max = ds[i][this.dsKeys[2]];// 最大阀值
				if(typeof(min) === 'undefined'){
					if(typeof(max) === 'undefined'){
						continue;
					}else{
						if(val < Number(max)){
							isFind = true;
							status = ds[i][this.dsKeys[0]];
							break;
						}
					}
				}else{
					if(val >= Number(min)){
						if(typeof(max) === 'undefined'){
							isFind = true;
							status = ds[i][this.dsKeys[0]];
							break;
						}else{
							if(val < Number(max)){
								isFind = true;
								status = ds[i][this.dsKeys[0]];
								break;
							}
						}
					}
				}
			}
			if(!isFind || typeof(status) === 'undefined'){
				return false;
			}
			this.status = status;
			return true;
		};
		/**
		 * 初始化赋值
		 */
		this.init = function(option){
			this.pcId = option.pcId;
			if(typeof(option.gap) != 'undefined'){
				this.gap =  option.gap;
			}
			if(typeof(option.width) != 'undefined'){
				this.width = option.width;
			}
			if(typeof(option.height) != 'undefined'){
				this.height = option.height;
			}
			if(typeof(option.arrowSize) != 'undefined'){
				this.arrowSize = option.arrowSize;
			}
		};
		/**
		 * 创建
		 */
		this.create = function(){
			// 整个div宽=块宽+左右各半个游标箭头宽度
			var adw = this.width + this.arrowSize;
			// 红、黄、绿各块宽((整个div宽-两个间隙-两端各游标箭头一半)/三块)
			var bw = (adw - (this.gap * 2) - this.arrowSize) / 3;
			// 游标箭头位置(x),默认绿块中间,游标箭头一半+红块+间隙+黄块+间隙+绿块一半-游标箭头一半
			var cx = (this.arrowSize / 2) + (bw * 2) + (this.gap * 2) + (bw / 2) - (this.arrowSize / 2);
			if(this.status == 2){
				// 黄块中间,游标箭头一半+红块+间隙+黄块一半-游标箭头一半
				cx = (this.arrowSize / 2) + bw + this.gap + (bw / 2) - (this.arrowSize / 2);
			}else if(this.status == 3){
				// 红块中间,游标箭头一半+红块一半-游标箭头一半
				cx = (this.arrowSize / 2) + (bw / 2) - (this.arrowSize / 2);
			}
			// 间隙块div
			var gd = '<div style="float: left;width: '+ this.gap +'px;height: '+ this.height +'px;"></div>';
			// 红块div
			var rbd = '<div style="float: left;width: '+ bw +'px;height: '+ this.height +'px;background: '+ this.colors[0] +'"></div>';
			// 黄块div
			var ybd = '<div style="float: left;width: '+ bw +'px;height: '+ this.height +'px;background: '+ this.colors[1] +'"></div>';
			// 绿块div
			var gbd = '<div style="float: left;width: '+ bw +'px;height: '+ this.height +'px;background: '+ this.colors[2] +'"></div>';
			// 游标箭头块
			var cad = '<div style="width: '+ adw +'px;height: '+ this.arrowSize +'px;'
								+'background: url(\''+ this.cursorArrow[this.status - 1] +'\') '+ cx +'px center no-repeat;'
								+'background-size: '+ this.arrowSize +'px '+ this.arrowSize +'px;"></div>';
			// 滑块
			var sd = '<div style="width: '+ adw +'px;height: '+ this.height +'px;padding-left: '+ (this.arrowSize / 2) +'px">'
						+ rbd + gd + ybd + gd + gbd +'</div>';
			// 添加到父div，游标div+滑块div
			$('#'+ this.pcId).html(cad + sd);
			// 父div宽高
			$('#'+ this.pcId).width(adw);
			$('#'+ this.pcId).height(this.height + this.arrowSize);
		};
		if(this.judge(option)){
			this.init(option);
			this.create();
		}
	}
};


/**
 * 同比/环比块
 */
var MyUD = {
	/**
	 * 同比/环比：值 (上下)箭头
	 * @param option {}
	 *   {pcId:string} 父容器id，不能为空
	 *   {label:string} 标签(同比/环比)
	 *   {val:dobule} 值，不能为空
	 *   {thrshd:double} 阀值(val与thrshd比较,确定上下箭头,默认0)
	 *   {width:int} 宽
	 *   {height:int} 高
	 *   {fontSize:int} 字体大小
	 *   {fontWeigth:string} 字体加粗
	 *   {valWidth:int} 值区域宽度
	 *   {arrowWidth:int} 箭头区域宽度
	 *   {arrowSize:int} 箭头尺寸(图片宽高)
	 *   {unit:string} 单位
	 *   {hasArrow:boolean} 是否箭头
	 *   {explainWords:[]} 替换箭头的文字信息
	 *   {colorIndex: int} 颜色值下标，默认0
	 *   {isAbs: boolean} 是否绝对值显示，默认true
	 */
	udBlock: function(option){
		this.pcId;this.val;this.imgUrl;this.color;
		this.label = '同比：';
		this.thrshd = 0;
		// 宽
		this.width = 110;
		// 高
		this.height = 22;
		// 字体大小
		this.fontSize = 12;
		// 字体加粗
		this.fontWeight = 'normal';
		// 字体颜色数组[up,down]
		this.COLORS = [['#ff0000','#000000'],['#000000','#ff0000']];//#8bbf3a
		// 箭头数组
		this.ARROW_IMG_URL = [
              [CONTEXT_PATH +'/assets/proj/images/icon_t_r_u.png'
               ,CONTEXT_PATH +'/assets/proj/images/icon_t_b_d.png']
              ,[CONTEXT_PATH +'/assets/proj/images/icon_t_b_u.png'
                ,CONTEXT_PATH +'/assets/proj/images/icon_t_r_d.png']
  		];
		// 箭头url
		this.arrowImgUrl = this.ARROW_IMG_URL[0][0];
		// 值区域宽度
		this.valWidth = 35;
		// 箭头区域宽度
		this.arrowWidth = 18;
		// 箭头尺寸(图片宽高)
		this.arrowSize = 12;
		// 单位
		this.unit = '';
		// 是否有箭头
		this.hasArrow = true;
		//实际文字
		this.factWord = '';
		//替换箭头的文字信息，降值写前面，如：['减少','增加']
		this.explainWords = [];
		// 颜色下标
		this.colorIndex = 0;
		// 是否绝对值显示
		this.isAbs = true;
		/**
		 * 初始化
		 * @param option
		 */
		this.init = function(option){
			if(typeof(option) != 'undefined'){
				this.pcId = option.pcId;
				this.val = option.val;
				if(typeof(option.label) != 'undefined')
					this.label = option.label;
				if(typeof(option.thrshd) != 'undefined')
					this.thrshd = option.thrshd;
				if(typeof(option.width) != 'undefined')
					this.width = option.width;
				if(typeof(option.height) != 'undefined')
					this.height = option.height;
				if(typeof(option.fontSize) != 'undefined')
					this.fontSize = option.fontSize;
				if(typeof(option.fontWeight) != 'undefined')
					this.fontWeight = option.fontWeight;
				if(typeof(option.valWidth) != 'undefined')
					this.valWidth = option.valWidth;
				if(typeof(option.arrowWidth) != 'undefined')
					this.arrowWidth = option.arrowWidth;
				if(typeof(option.arrowSize) != 'undefined')
					this.arrowSize = option.arrowSize;
				if(typeof(option.unit) != 'undefined')
					this.unit = option.unit;
				if(typeof(option.hasArrow) != 'undefined')
					this.hasArrow = option.hasArrow;
				if(typeof(option.explainWords) != 'undefined')
					this.explainWords = option.explainWords;
				if(typeof(option.colorIndex) != 'undefined')
					this.colorIndex = option.colorIndex;
				if(typeof(option.isAbs) != 'undefined')
					this.isAbs = option.isAbs;
			}else{
				return false;
			}
			if(this.val < this.thrshd){
				this.color = this.COLORS[this.colorIndex][1];
				this.arrowImgUrl = this.ARROW_IMG_URL[this.colorIndex][1];
				if(this.explainWords.length > 1){
					this.factWord = this.explainWords[0];
				}
			}else{
				this.color = this.COLORS[this.colorIndex][0];
				this.arrowImgUrl = this.ARROW_IMG_URL[this.colorIndex][0];
				if(this.explainWords.length > 1){
					this.factWord = this.explainWords[1];
				}
			}
//			if(!this.hasArrow){
//				this.arrowWidth = 0;
//			}
		};
		this.create = function(){
			var lblTd = '<td style="width: '+ (this.width-this.arrowWidth-this.valWidth) +'px;height: '+ this.height +'px;vertical-align: middle;text-align: left;">'+ this.label +'</td>';
			var arwTd = '';
			if(this.hasArrow){
				arwTd = '<td style="width: '+ this.arrowWidth +'px;height: '+ this.height +'px;vertical-align: middle;text-align: center;"><img src="'+ this.arrowImgUrl +'" width="'+ this.arrowSize +'px" height="'+ this.arrowSize +'px"/></td>';
			}else{
				arwTd = '<td style="width: '+ this.arrowWidth +'px;height: '+ this.height +'px;vertical-align: middle;text-align: center;">'+ this.factWord +'</td>';
			}
			var valTd = '<td style="width: '+ this.valWidth +'px;height: '+ this.height +'px;vertical-align: middle;text-align: center;color: '+ this.color +';">'+ (this.isAbs ? Math.abs(this.val) : this.val) + this.unit +'</td>';
			var tb = '<table style="width: '+ this.width +'px;height: '+ this.height +'px;" border="0" cellpadding="0" cellspacing="0"><tr>'+ lblTd + arwTd + valTd +'<tr></table>';
			$('#'+ this.pcId).html(tb);
		};
		this.init(option);
		this.create();
	}
};

var LdBut = {
		initBut: function(){
			var buts = $('.bfbutton');
			for(var i=0; i<buts.length; i++){
				but = buts[i];
				$(but).attr("onmouseover","LdBut.overButton(this)");
				$(but).attr("onmouseout","LdBut.outButton(this)");
			}
		},
		
		overButton: function(obj){
			$(obj).css("background-color", "#00ccff");
		},
		
		outButton: function(obj){
			$(obj).css("background-color", "#0099FF");
		},
		
		/**
		 * 点击按钮显示
		 * @param obj
		 */
		downButton: function(obj){
			//father = obj.parentNode;
			$(obj).css("color","#000000");
			$(obj).css("background-color","#00ccff");
			$(obj).removeAttr("onmouseout");
		},

		/**
		 * 清理按钮样式
		 * @param obj
		 */
		upButton: function(obj){
			gfather = obj.parentNode.parentNode;
			fathers = gfather.childNodes;
			for(var i=0; i<fathers.length; i++){
				father = fathers[i];
				childs = father.childNodes;
				for(var j=0; j<childs.length; j++){
					child = childs[j];
					if(!(typeof(child) === "undefined") 
						&& (child.className+"").indexOf('bfbutton') !== -1){
						child.style.color = "#FFFFFF";
					}
					if(!(typeof(child) === "undefined") 
						&& child.className === 'slid'){
						$(child).remove();
					}
					if(child.tagName === "A" ){
						$(child).css("background-color","#0099FF");
						$(child).attr("onmouseout","LdBut.outButton(this)");
					}
				}
				if(father.tagName === "LI" && 
					($(father).css("background-image") !== "none" || 
					$(father).css("background-color") !== "none")){
					$(father).css("background-image","");
					$(father).css("background-color","");
				}
			}

			//if($(father).css("background-image") !== null){
			//	$(father).css("background-image","");
			//}
		},
		
		down: function(obj){
			LdBut.upButton(obj);
			LdBut.downButton(obj);
		}
};

var ControlUtil = {
		/**
		 * 根据传入阀值数组确定颜色
		 * {min:int}		已知最小值(存在阀值最小值未知的情况)
		 * {max:int}		已知最大值(存在阀值最大值未知的情况)
		 * {keys:[]}			阀值json取值关键字顺序 {状态值，最小阀值，最大阀值}
		 * {arrs:[]}			阀值区间数组
		 * {colors:json}	状态值与颜色关系，如：{'1':'#8bbf3a','2':'#ffff00','3':'#ff0000'}
		 * 
		 * 返回值：
		 * 正常：{color:[], thrshds:[], errcode:str}
		 * 异常：{errcode:str}
		 * 异常编码:  
		 * 400: 正常
		 * 500: 阀值区间存在最小值比最大值 还要大的情况
		 * 501: 传入阀值数组长度为0
		 * 
		 * 描述：
		 * color：滑块颜色顺序 0->N 颜色从左到右顺序
		 * thrshds：阀值小到大顺序
		 */
		sliderColors:function(param){
			var resultColor = [];
			var sortIndex = "";
			var keys = !(typeof(param.keys) === 'undefined') ? param.keys : ["THRSHD_STTS","MIN_THRSHD","MAX_THRSHD"];
			var arrs = !(typeof(param.arrs) === 'undefined') ? param.arrs : [];
			var colors = !(typeof(param.colors) === 'undefined') ? param.colors : {'1':'#8bbf3a','2':'#ffff00','3':'#ff0000'};//1.正常(绿) 2.预警(黄) 3.告警(红);
			var thrshds = [];
			//迭代方法，取最大最小值序列
			var iterator = function(arrs,sortIndex,keys){
				var minIndex = -1;
				var maxIndex = -1;
				var minNum = 9999;
				var maxNum = -1;
				for(var i=0; i<arrs.length; i++){
					thrshd = arrs[i];
					if(sortIndex.indexOf(i) !== -1) {
						continue;
					}
					if(thrshd[keys[1]] === '' || thrshd[keys[1]] === null || typeof(thrshd[keys[1]]) === 'undefined'){
						minIndex = i;
						minNum = (typeof(param.min)==='undefined')?-1:param.min;
					}else if(thrshd[keys[2]] === '' || thrshd[keys[2]] === null || typeof(thrshd[keys[2]]) === 'undefined'){
						maxIndex = i;
						maxNum = (typeof(param.max)==='undefined')?9999:param.max;
					}else{
						if(parseFloat(thrshd[keys[1]]) > parseFloat(thrshd[keys[2]])){
							return '500';
						}
						if(parseFloat(thrshd[keys[1]]) < minNum){
							minNum = thrshd[keys[1]];
							minIndex = i;
						}
						if(parseFloat(thrshd[keys[2]]) > maxNum){
							maxNum = thrshd[keys[2]];
							maxIndex = i;
						}
					}
				}
				if(minIndex !== -1 && maxIndex !== -1){
					if(minIndex === maxIndex) return minIndex;
					return minIndex+","+maxIndex;
				}
			};
			if(arrs.length === 0){return '501';};
			for(var i=0; i<arrs.length/2; i++){
				inteResult = iterator(arrs,sortIndex,keys);
				if(inteResult === '500') return {"errcode":inteResult};
				if(sortIndex.length === 0) sortIndex = inteResult;
				else {
					sortIndex = sortIndex.substring(0,(sortIndex.length/2))+","+inteResult
						+","+sortIndex.substring((sortIndex.length/2)+1,sortIndex.length);
				}
			}
			indexs = sortIndex.split(',');
			for(var i=0; i<indexs.length; i++){
				//按阀值值域顺序给数组附上颜色
				resultColor[i] = colors[arrs[indexs[i]][keys[0]]];
				min = arrs[indexs[i]][keys[1]];
				max = arrs[indexs[i]][keys[2]];
				if((min === '' || min === null || typeof(min) === 'undefined') && !(typeof(param.min) === 'undefined')){
					min = param.min;
				}
				if((max === '' || max === null || typeof(max) === 'undefined') && !(typeof(param.max) === 'undefined')){
					max = param.max;
				}
				if(i===0){
					thrshds[i] = min;
					thrshds[i+1] = max;
				}else{
					thrshds[i+1] = max;
				}
			}
			return {"color":resultColor,
				"thrshds":thrshds,
				"errcode":"400"};
		}
};